#ifndef PROPERTYITEM_HPP
#define PROPERTYITEM_HPP

#include <QObject>
#include "common.hpp"
class PropertyItem : public QObject
{
    Q_OBJECT
public:
    explicit PropertyItem(PropertyItem *parent = nullptr);
    ~PropertyItem();

    PropertyItem *getParent() const;
    QString data(int column);

    bool setBuildItemsByDBusArg(const QString &DBusArgs);
    void setValues(const QString &Values);
    bool setValues(const DVariant &Values);
    bool checkDictKey(const QString &Values);
    bool isBaseType();

    DVariant getValue();
    int childCount() const
    {
        return childItems.count();
    }
    int row() const
    {
        if (parentItem!=Q_NULLPTR)
        {
            return parentItem->childItems.indexOf(const_cast<PropertyItem*>(this));
        }
        return 0;
    }
    void clear()
    {
        foreach (auto var, childItems) {
            var->clear ();
        }
        qDeleteAll(childItems);
        childItems.clear ();
    }

    PropertyItem * getChildItem(const int row) const
    {
        if(childItems.count ()>row)
            return childItems.at (row);
        return Q_NULLPTR;
    }

    int getIsDict() const;
    void setIsDict(int isDict);

    int getType() const;
    void setType(int Type);

    QString getName() const;
    void setName(const QString &Name);

signals:

public slots:
public:
    QList<PropertyItem*> childItems;
    PropertyItem* parentItem;
    QList<int> m_Subtypes;
    QString m_Name;
    QString m_TypeName;
    QString m_Values;
    int m_Type;
    int m_isDict;
};

#endif // PROPERTYITEM_HPP
